package org.zfes.snowier.cloud.zbss.pmp.router.service.ma;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.zfes.snowier.cloud.zbss.pmp.dto.PmpProjectCreateDto;
import org.zfes.snowier.cloud.zbss.pmp.dto.PmpProjectUpdateDto;
import org.zfes.snowier.cloud.zbss.pmp.dto.PmpProjectVersionCreateDto;
import org.zfes.snowier.cloud.zbss.pmp.service.IPmpProjectService;
import org.zfes.snowier.cloud.zbss.pmp.service.IPmpProjectVersionService;
import org.zfes.snowier.cloud.zbss.pmp.service.IpmpProjectGroupService;
import org.zfes.snowier.core.data.ComboboVo;
import org.zfes.snowier.core.data.DataSet;
import org.zfes.snowier.web.controller.BaseController;

import java.util.List;
import java.util.Map;

@Controller("org.zfes.snowier.cloud.zbss.pmp.router.service.ma.pmpProjectController")
@RequestMapping("/pmp/service/ma/pmpProject")
public class PmpProjectController extends BaseController {

    @Autowired
    private IPmpProjectService pmpProjectService;

    @Autowired
    private IPmpProjectVersionService projectVersionService;
	@Autowired
	private IpmpProjectGroupService pmpProjectGroupService;
   
    @RequestMapping(value="/createPmpProject", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody Object createPmpProject(PmpProjectCreateDto pmpProjectDto){
        pmpProjectService.createPmpProject(pmpProjectDto);
        return ajaxDoneSuccess("数据操作成功 ");
    }


    @RequestMapping(value="/updatePmpProject", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object updatePmpProject( PmpProjectUpdateDto pmpProjectDto){
        pmpProjectService.updatePmpProject(  pmpProjectDto);
        return ajaxDoneSuccess("数据操作成功 ");
    }

    @RequestMapping(value="/loadPmpProjectDataSet", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object loadPmpProjectDataSet(@RequestParam Map<String,Object> params){
        DataSet dataSet=  pmpProjectService.loadPmpProjectDataSet(params);
        return ajaxQuery("dataSet", dataSet);
    }
    
    @RequestMapping(value="/loadPmpProjectComboboVo", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object loadPmpProjectComboboVo(Boolean firstEmpty){
		 List<ComboboVo>  vo=pmpProjectService.loadComboboVo(firstEmpty);
	    return ajaxQuery("comboboVo", vo);
    }
    //#0未开始，1进行中，2结束，3暂停中，4关闭-1删除 #
    @RequestMapping(value="/setPmpProjectStatus", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object setPmpProjectStatus(Long id,Byte status ){
        pmpProjectService.setPmpProjectStatus(id, status);
        return ajaxDoneSuccess("数据操作成功 ");
    }
    
//==========================ProjectGroup=================================   
    
    @RequestMapping(value = "/createPmpVersion",method = RequestMethod.POST,produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody Object createPmpVersion(PmpProjectVersionCreateDto versionCreateDto){
    	projectVersionService.createPmpProjectVersion(versionCreateDto);
        return ajaxDoneSuccess("数据操作成功");
    }

    
    @RequestMapping(value = "/updatePmpVersion",method = RequestMethod.POST,produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody Object updatePmpVersion(Long id,Long versionId){
        pmpProjectService.updatePmpProjectVersion(id,versionId);
        return ajaxDoneSuccess("版本更新成功");
    }
    //==========================ProjectGroup=================================
    
    @RequestMapping(value="/addOneProjectGroupMember", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object addOneProjectGroupMember(Long projectId,Long userId,Byte userType){
		pmpProjectGroupService.addOnePmpProjectGroupMember(projectId,userId,userType);
		return ajaxDoneSuccess("数据操作成功 ");
    }
    
    @RequestMapping(value="/deleteOneProjectGroupMember", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object deletePmpProjectGroupMember(Long projectId,Long userId,Byte userType){
		pmpProjectGroupService.deleteOnePmpProjectGroupMember(projectId,userId,userType);
		return ajaxDoneSuccess("数据操作成功 ");
    }

}
